home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Arsenal Files 8
/
The Arsenal Files Collection #8 (Arsenal Computer) (1996).ISO
/
g_quake
/
godelqc5.zip
/
TEAMPLAY.QC
< prev
next >
Wrap
Text File
|
1996-09-20
|
15KB
|
593 lines
float checktime;
//prototypes
void() ActivateFlag;
void (entity temp_ent) GiveQuakePower = {
temp_ent.items = temp_ent.items | IT_QUAD;
temp_ent.super_time = 1;
temp_ent.super_damage_finished = time + 1000;
};
void (entity temp_ent) RemoveQuakePower = {
temp_ent.items = temp_ent.items - (temp_ent.items & IT_QUAD);
temp_ent.super_damage_finished = 0;
temp_ent.super_time = 0;
};
void (entity ent) MakeIt = {
local string s;
if (teamplay == 6) GiveQuakePower(ent);
if(teamplay==4) {
if (!(ent.flags & FL_AM_IT)) centerprint(ent,"You're IT!\n");
ent.items=ent.items | IT_KEY1;
ent.items=ent.items - (ent.items & IT_KEY2);
ent.effects=ent.effects | EF_DIMLIGHT;
stuffcmd(ent,"COLOR 4 ");
s=ftos(ent.team - 1);
stuffcmd(ent,s);
stuffcmd(ent,"\n");
} else if((teamplay==5)||(teamplay==6)) {
if (!(ent.flags & FL_AM_IT)) centerprint(ent,"You're TI!\n");
ent.items=ent.items | IT_KEY2;
ent.items=ent.items - (ent.items & IT_KEY1);
ent.effects=ent.effects | EF_DIMLIGHT;
stuffcmd(ent,"COLOR 4 ");
s=ftos(ent.team - 1);
stuffcmd(ent,s);
stuffcmd(ent,"\n");
}
ent.flags=ent.flags | FL_AM_IT;
};
void (entity ent) MakeNotIt = {
local string s;
if (teamplay == 6) RemoveQuakePower(ent);
if(teamplay==4) {
if (!(ent.flags & FL_AM_IT)) centerprint(ent,"You're not IT anymore!\n");
ent.items=ent.items - (ent.items & IT_KEY1);
ent.items=ent.items - (ent.items & IT_KEY2);
stuffcmd(ent,"COLOR 2 ");
s=ftos(ent.team - 1);
stuffcmd(ent,s);
stuffcmd(ent,"\n");
} else if((teamplay==5)||(teamplay==6)) {
if (!(ent.flags & FL_AM_IT)) centerprint(ent,"You're not TI anymore!\n");
ent.items=ent.items - (ent.items & IT_KEY1);
ent.items=ent.items - (ent.items & IT_KEY2);
stuffcmd(ent,"COLOR 2 ");
s=ftos(ent.team - 1);
stuffcmd(ent,s);
stuffcmd(ent,"\n");
}
ent.flags=ent.flags-(ent.flags & FL_AM_IT);
ent.effects=ent.effects-(ent.effects * EF_DIMLIGHT);
};
void() RemoveFlagsAndBases = {
local entity head;
head=find(world,classname,"base");
while(head){
remove(head);
head=find(world,classname,"base");
}
head=find(world,classname,"flag");
while(head){
remove(head);
head=find(world,classname,"flag");
}
world_flag=3;
};
void() RemoveHill = {
local entity head;
head=find(world,classname,"hill");
while(head){
remove(head);
head=find(world,classname,"hill");
}
world_hill=0;
};
void() CheckTeamPlayChange = {
local entity head;
if(teamplay!=oldteamplay){
if (oldteamplay==6){
head=find(world,classname,"player");
while(head){
RemoveQuakePower(head);
head=find(head,classname,"player");
}
}
if (oldteamplay==7){
head=find(world,classname,"player");
while(head){
head.items=head.items-(head.items & IT_KEY1);
head.items=head.items-(head.items & IT_KEY2);
head.flaginv=0;
head=find(head,classname,"player");
}
}
if(teamplay==0) bprint("No Teams Mode\n");
else if(teamplay==1) bprint("Normal Team Mode\n");
else if(teamplay==2) bprint("Damage Team Mode\n");
else if(teamplay==4) bprint("IT Mode\n");
else if(teamplay==5) bprint("TI Mode\n");
else if(teamplay==6) bprint("Quake-TI Mode\n");
else if(teamplay==7) bprint("Capture the Flag Mode\n");
else if(teamplay==8) bprint("King of the Hill Mode\n");
oldteamplay=teamplay;
self.impulse=17; // remove flags/bases/hills
}
};
void() HillThink = {
local entity head;
head=findradius(self.origin,200);
while(head){
if((head.classname=="player") && (head.health > 0) && (!(head.flags & FL_OBSERVER))) {
sound(head,CHAN_BODY,"misc/talk.wav",0.1,ATTN_NORM);
head.frags=head.frags+0.1;
}
head=head.chain;
}
self.nextthink=time+1;
if (!world_hill) remove(self);
};
void() PlaceHill = {
local entity hill;
if(!world_hill){
bprint(self.netname);
bprint(" placed the Hill\n");
world_hill=1;
hill=spawn();
setmodel(hill,"progs/end4.mdl");
hill.classname="hill";
setorigin(hill,self.origin);
hill.movetype = MOVETYPE_TOSS;
hill.solid = SOLID_NOT;
hill.think = HillThink;
hill.nextthink = time + 0.1;
setsize (hill, VEC_ORIGIN, VEC_ORIGIN);
hill.effects = hill.effects | EF_DIMLIGHT;
}
};
void() CheckBase = {
local entity newflag;
local entity oldbase,entity;
local float flag_color;
self.think = CheckBase;
self.nextthink = time + 1;
if (world_flag & self.items) remove(self);
else if (self.watertype < -3) {
flag_color = self.items;
if (flag_color == FLAG_1)
bprint ("Silver ");
if (flag_color == FLAG_2)
bprint ("Gold ");
bprint("Base unreachable. Removing.");
world_flag=world_flag+self.items;
remove(self);
}
};
void() CheckFlag = {
local entity newflag;
local entity oldbase,entity;
local float flag_color;
self.think = CheckFlag;
self.nextthink = time + 1;
if (world_flag & self.items) {
remove(self);
}
else if (self.watertype < -3) {
flag_color = self.items;
if (flag_color == FLAG_1)
bprint ("Silver ");
if (flag_color == FLAG_2)
bprint ("Gold ");
bprint("flag unreachable. Respawning.");
remove(self);
oldbase = world;
while (oldbase.items != flag_color)
oldbase = find(oldbase,classname,"base");
newflag = spawn();
newflag.owner = oldbase;
newflag.movetype = MOVETYPE_NONE;
newflag.solid = SOLID_NOT;
newflag.items = flag_color;
newflag.classname = "flag";
newflag.think = ActivateFlag;
newflag.nextthink = time + 0.5;
setsize (newflag, VEC_ORIGIN, VEC_ORIGIN);
setorigin (newflag, oldbase.origin);
newflag.pos1 = newflag.origin;
newflag.velocity = VEC_ORIGIN;
if (flag_color == FLAG_1) setmodel(newflag,"progs/m_s_key.mdl");
else setmodel(newflag,"progs/m_g_key.mdl");
}
};
void(entity who,float flag_color) ReturnFlagToBase = {
local entity newflag;
local float team_color,flag_color;
local entity head;
team_color=who.team;
sound (who, CHAN_WEAPON, "misc/secret.wav", 1, ATTN_NORM);
newflag = spawn();
newflag.owner = self;
newflag.movetype = MOVETYPE_NONE;
newflag.solid = SOLID_NOT;
newflag.items = flag_color;
newflag.classname = "flag";
newflag.think = ActivateFlag;
newflag.nextthink = time + 0.1;
setsize (newflag, VEC_ORIGIN, VEC_ORIGIN);
head = world;
while(head.items != flag_color)
head = find(head,classname,"base");
setorigin (newflag, head.origin);
newflag.pos1 = newflag.origin;
newflag.velocity = VEC_ORIGIN;
if (flag_color == FLAG_1)
setmodel(newflag,"progs/m_s_key.mdl");
else
setmodel(newflag,"progs/m_g_key.mdl");
who.flaginv=who.flaginv-flag_color;
if (who.team==flag_color) who.flagtime=0;
};
void() PickupFlag = {
local float team_color;
local float flag_color;
local entity newflag;
local entity oldbase;
if (world_flag) return;
if (other == world) return;
if (other.classname != "player") return;
flag_color = self.items;
team_color = other.team;
if (team_color > 2)
{
centerprint(other,"You must be on Silver or Gold team\n");
centerprint(self,"Type COLOR x 0 or COLOR x 1\n");
return;
}
if ((flag_color == team_color) && (self.origin_x == self.pos1_x) && (self.origin_y == self.pos1_y))
{
// You cannot take your flag from your base
return;
}
bprint(other.netname);
bprint(" picked up the ");
if (flag_color == FLAG_1) bprint("silver flag.\n");
if (flag_color == FLAG_2) bprint("gold flag.\n");
sound (self, CHAN_WEAPON, "misc/secret.wav", 1, ATTN_NORM);
if (flag_color == team_color) {
other.flagtime = time + 30;
}
other.flaginv = other.flaginv + flag_color;
remove(self);
};
void() ActivateFlag =
{
local entity newflag;
local entity oldbase;
local float flag_color;
self.owner = self;
self.movetype = MOVETYPE_TOSS;
self.solid = SOLID_TRIGGER;
self.touch = PickupFlag;
self.think = CheckFlag;
self.effects = self.effects | EF_DIMLIGHT;
self.nextthink = time + 5;
if (world_flag) {
self.pos1 = self.origin;
}
};
void() TouchBase = {
local float team_color;
local float base_color;
local entity oldbase,head;
local entity newflag;
if (other == world) return;
if (other.classname != "player") return;
if(other.flaginv==0) return;
base_color = self.items;
team_color = other.team;
if (team_color > 2) {
centerprint(other,"You must be on Silver or Gold team\n");
centerprint(self,"Type COLOR x 0 or COLOR x 1\n");
return;
}
if (team_color == base_color) {
if (other.flaginv & base_color) {
bprint(other.netname);
bprint(" returns the flag to his base\n");
ReturnFlagToBase(other,base_color);
}
if (other.flaginv & (FLAG_BOTH - team_color)) {
// Give the team scores
bprint(other.netname);
bprint(" secures ");
if (team_color == FLAG_1)
bprint("Gold flag.\n");
if (team_color == FLAG_2)
bprint("Silver flag.\n");
other.frags = other.frags + 5;
head = find(world,classname,"player");
while(head){
if (head.team==team_color)
head.frags=head.frags+5;
head = find(head,classname,"player");
}
ReturnFlagToBase(other,(FLAG_BOTH - team_color));
}
}
};
void() ActivateBase =
{
local entity found;
self.owner = self;
self.movetype = MOVETYPE_TOSS;
self.solid = SOLID_TRIGGER;
self.touch = TouchBase;
self.think = CheckBase;
self.nextthink = time+1;
if (world_flag == 0)
{
bprint("Flags placed. Let the Games begin!\n");
return;
}
};
void (float flag_color) PlaceBase =
{
local entity newbase;
newbase = spawn();
newbase.owner = self;
newbase.movetype = MOVETYPE_NONE;
newbase.solid = SOLID_NOT;
newbase.items = flag_color;
newbase.classname = "base";
newbase.think = ActivateBase;
newbase.nextthink = time + 1;
setsize (newbase, VEC_ORIGIN, VEC_ORIGIN);
setorigin (newbase, self.origin + '0 0 3');
newbase.velocity = VEC_ORIGIN;
if (flag_color == 1) setmodel(newbase,"progs/w_s_key.mdl");
else setmodel(newbase,"progs/w_g_key.mdl");
world_flag = world_flag - flag_color;
};
void(float flag_color) DropFlag = {
local entity newflag;
newflag = spawn();
newflag.owner = self;
newflag.movetype = MOVETYPE_NONE;
newflag.solid = SOLID_NOT;
newflag.items = flag_color;
newflag.classname = "flag";
newflag.think = ActivateFlag;
newflag.nextthink = time + 1;
setsize (newflag, VEC_ORIGIN, VEC_ORIGIN);
setorigin (newflag, self.origin);
newflag.velocity_x = 250*random();
newflag.velocity_y = 250*random();
if (flag_color == FLAG_1) setmodel(newflag,"progs/m_s_key.mdl");
else setmodel(newflag,"progs/m_g_key.mdl");
self.attack_finished = time + 1;
self.flaginv=self.flaginv-flag_color;
};
void(float both) DropFlagCheck = {
local float flag_color;
local entity newflag;
if (teamplay != 7) {
return;
}
flag_color=self.flaginv;
if (flag_color == 3) {
// you have both flags drop just yours.
// FIX maybe drop just opponents. not sure.
if (both){
DropFlag(FLAG_1);
DropFlag(FLAG_2);
} else {
flag_color=self.team;
DropFlag(flag_color);
}
} else if (flag_color > 0){
DropFlag(flag_color);
}
if (flag_color & self.team) self.flagtime=0;
};
void() W_PlaceFlag =
{
if (world_flag == 0)
{
bprint("Both Flags already placed.\n");
return;
}
if (self.team == 1)
{
if (world_flag & FLAG_1)
{
bprint("Silver Flag Placed by ");
bprint(self.netname);
bprint("\n");
PlaceBase(FLAG_1);
ReturnFlagToBase(self,FLAG_1);
return;
}
else
{
centerprint(self,"Silver flag already dropped\n");
return;
}
}
if (self.team == 2)
{
if (world_flag & FLAG_2)
{
bprint("Gold Flag Placed by ");
bprint(self.netname);
bprint("\n");
PlaceBase(FLAG_2);
ReturnFlagToBase(self,FLAG_2);
return;
}
else
{
centerprint(self,"Gold flag already dropped\n");
return;
}
}
if (self.team > 2)
{
centerprint(self,"You must be on Silver or Gold team\n");
centerprint(self,"Type COLOR x 0 or COLOR x 1\n");
return;
}
};
void (entity targ, entity attacker, float makeit) CheckTeamRules= {
local entity temp_ent,head;
local float dist;
if ((teamplay == 7) && targ.flaginv) {
bprint(targ.netname);
bprint(" died carrying ");
if (targ.flaginv == FLAG_BOTH)
bprint("Both flags.\n");
else if (targ.flaginv == FLAG_1)
bprint("Silver flag.\n");
else if (targ.flaginv == FLAG_2)
bprint("Gold flag.\n");
temp_ent = self;
self = targ;
DropFlagCheck(TRUE);
self = temp_ent;
}
// make closest player TI upon death
if ((attacker.classname != "player") || (attacker == targ)){
if(((teamplay!=5) && (teamplay!=6)) && (!makeit)) return;
dist=100;
while(!head && (dist < 4000)){
head=findradius(targ.origin,dist);
while(head){
if((head.classname=="player")&&(head!=targ)&&(dist<4000)){
MakeNotIt(targ);
MakeIt(head);
dist=4000;
}
head=head.chain;
}
dist=dist+100;
}
return;
}
// only non its can frag
if(teamplay == 4) {
if (attacker.flags & FL_AM_IT) {
MakeIt(targ);
MakeNotIt(attacker);
attacker.frags=attacker.frags - 1;
} else {
if (targ.flags & FL_AM_IT)
attacker.frags = attacker.frags + 2;
}
}
//ti gets 3 frags for killing
if(teamplay == 5) {
if (!(attacker.flags & FL_AM_IT)) {
if (targ.flags & FL_AM_IT) {
MakeIt(attacker);
MakeNotIt(targ);
}
} else {
// give three frags if kill he killed a non-ti
if (!(targ.flags & FL_AM_IT)) {
attacker.frags = attacker.frags + 2;
} else {
MakeIt(attacker);
MakeNotIt(targ);
}
}
}
if(teamplay == 6) {
if (!(attacker.flags & FL_AM_IT)) {
if (targ.flags & FL_AM_IT) {
MakeIt(attacker);
MakeNotIt(targ);
attacker.frags = attacker.frags + 2;
}
} else if (targ.flags & FL_AM_IT) {
MakeIt(attacker);
MakeNotIt(targ);
}
}
};
void() CheckTeamPlay = {
local float found_it;
local entity head;
if (teamplay > 3 && teamplay < 9) {
if (teamplay == 7) {
if (((world_flag == 0) && (self.flaginv & FLAG_1)) ||
((world_flag & FLAG_1) && (self.team == FLAG_1))) {
self.items = self.items | IT_KEY1;
self.flaginv = self.flaginv | FLAG_1;
self.effects = self.effects | EF_DIMLIGHT;
} else self.items = self.items - (self.items & IT_KEY1);
if (((world_flag == 0) && (self.flaginv & FLAG_2)) ||
((world_flag & FLAG_2) && (self.team == FLAG_2))) {
self.items = self.items | IT_KEY2;
self.flaginv = self.flaginv | FLAG_2;
self.effects = self.effects | EF_DIMLIGHT;
} else self.items = self.items - (self.items & IT_KEY2);
if ((self.flagtime < time) && self.flagtime) {
bprint(self.netname);
bprint("'s flag returned to his base\n");
ReturnFlagToBase(self,self.team);
}
}
if (checktime > time) return;
if((teamplay >3) && (teamplay < 7)){
head=find(world,classname,"player");
while(head){
if (head.flags & FL_AM_IT) {
found_it=TRUE;
MakeIt(head);
} else {
MakeNotIt(head);
}
head=find(head,classname,"player");
}
if (!found_it) {
MakeIt(self);
}
}
}
checktime=time + 5;
};